package com.program.cloudmanagesystem.hotel.controller;
import com.program.cloudmanagesystem.hotel.domain.*;
import com.program.cloudmanagesystem.hotel.service.VehicleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//import javax.jws.WebParam;
//import javax.jws.soap.SOAPBinding;
import java.util.List;
@RestController
@RequestMapping("/Vehicle")
public class VehicleController {
    @Autowired
    private VehicleService vehicleService;

    @GetMapping("/Vehicle")
    public List<Vehicle> showVehicles(){
        return vehicleService.showVehicles();
    }

    @GetMapping("/searchVehicle")
    public Vehicle searchVehicle(@RequestBody Vehicle vehicle){
        return vehicleService.searchVehicle(vehicle.getLisence());
    }

    @PostMapping("/insertVehicle")
    public String insertVehicle(@RequestBody Vehicle vehicle){
        vehicleService.insertVehicle(vehicle);
        return "OK";
    }

    @PostMapping ("/deleteVehicle")
    public String deleteVehicle(@RequestBody Vehicle vehicle){
        vehicleService.deleteVehicle(vehicle.getId());
        return "OK";
    }

    @PostMapping("/updateData")
    public String updateData(@RequestBody Vehicle vehicle){
        vehicleService.updateData(vehicle);
        return "OK";
    }
    @PostMapping("/searchVehiclesByHotelId")
    public List<Vehicle> searchVehiclesByHotelId(@RequestBody Hotel hotel){
        return vehicleService.showVehiclesByHotelId(hotel.getId());
    }
}
